#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>

using namespace std;

void Test1()
{

}

struct ListNode
{
    int val = 0;
    ListNode* next = nullptr;
};

struct ListNode* FindFirstCommonNode(struct ListNode* pHead1, struct ListNode* pHead2) {
    struct ListNode* h1 = pHead1;
    struct ListNode* h2 = pHead2;
    while (h1)
    {
        while (h2)
        {
            if (h1->val == h2->val) return h2;
            else h2 = h2->next;
        }
        h2 = pHead2;
        h1 = h1->next;
    }
    return NULL;
}

int getsize(ListNode* h)
{
    int _size = 0;
    while (h)
    {
        _size++;
        h = h->next;
    }
    return _size;
}

struct ListNode* FindFirstNode(struct ListNode* pHead1, struct ListNode* pHead2)
{
    ListNode* h1 = pHead1;
    ListNode* h2 = pHead2;

    int h1_size = getsize(h1);
    int h2_size = getsize(h2);
    int n = abs(h1_size - h2_size);

    if (h1_size > h2_size)
    {
        while (n--)
        {
            h1 = h1->next;
        }
    }
    else
    {
        while (n--)
        {
            h2 = h2->next;
        }
    }

    while (h1 && h2)
    {
        if (h1->val == h2->val) return h1;
        else
        {
            h1 = h1->next;
            h2 = h2->next;
        }
    }
    return nullptr;
}


int main() {

    long long n, m, a, b, _max = 0;
    cin >> n >> m >> a >> b;
    for (int i = 0; 2 * i <= n && i <= m; i++)
    {
        long long n2 = n - i * 2;
        long long m2 = m - i;
        long long j = min(n2, m2 / 2);
        long long sum = i * a + j * b;
        _max = max(_max, sum);
    }
    cout << _max << endl;
    return 0;
}